package com.itheima.zuoye2;

import java.util.concurrent.ArrayBlockingQueue;

public class Foodie extends Thread{
//    Desk desk = new Desk();
//    public Foodie(Desk desk){
//
//    }
    @Override
    public void run() {
        while (true){
            synchronized (Desk.lock){
                if(Desk.count==0){
                    break;
                }else {
                    if (Desk.flag){
                        System.out.println("吃货在吃汉堡包");
                        Desk.flag = false;
                        Desk.lock.notifyAll();
                        Desk.count--;
                    }else {
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
